package com.googlecode.jlogalizerweb.web;

import java.io.File;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class DisplayController implements Controller {

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		System.out.println("in Display controller.....");
		File targetFile = new File("/tmp", "processoutput.log");

		PrintWriter out = response.getWriter();
		
		String fileLines = FileUtils.readFileToString(targetFile);
		
		out.println(fileLines);
		
		out.println ("done");
		
		out.flush();
		
		/*
		PrintWriter out = response.getWriter();
		String line;
		BufferedReader input = new BufferedReader(new FileReader(targetFile));
		while ((line = input.readLine()) != null) {
			System.out.println("Line is " + line);
			out.println(line);
		}
		input.close();

*/		System.out.println("file read done !!!");

		return null;

	}

}
